package lang;

import org.junit.Test;

public class MxString {
    private String mx = "MX";

    public static void main(String[] args) {
        String account = "xian-SG";

        String prefix = account.substring(0, account.length() - 4);
        String suffix = account.substring(account.length() - 4, account.length() - 1);

        System.out.println(prefix);
        System.out.println(suffix);

        System.out.println(account.substring(0, 7));

        System.out.println(account.lastIndexOf("xian"));
    }

    @Test
    public void mxIntern() {
        System.out.println("MX".intern() == mx);
    }


    @Test
    public void mxFormat() {
        String string = String.format("%s", "ABC");
        System.out.println(string);
    }

    @Test
    public void replaceAll(){
        String string = "{\"token\":[-24,18,-92,-107,22,3,-98,-103,8,127,-95,100,-35,-108,82,-80,51,-88,43,-88,-103,104,10,-65,-123,34,127,16,-12,-60,15,-74,30,16,22,-6,-9,6,74,98],\"data\":\"[{\\\"symbol\\\":\\\"00700.HK\\\",\\\"side\\\":\\\"Buy\\\",\\\"type\\\":\\\"Limit\\\",\\\"price\\\":100,\\\"quantity\\\":100},{\\\"symbol\\\":\\\"00700.HK\\\",\\\"side\\\":\\\"Buy\\\",\\\"type\\\":\\\"Limit\\\",\\\"price\\\":100,\\\"quantity\\\":1000}]\",\"delay\":false,\"triggerTime\":\"2018-01-09 23:45:36\"}";
        String replaced = string.replaceAll("\\\\", "");
        System.out.println(replaced);
    }
}
